﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SocketClientCSharp
{
    class Program
    {
        static void Main(string[] args)
        {
            var client = new ClientMgr("127.0.0.1",1000);
            try
            {
                client.ReceiveEvent += Client_ReceiveEvent;
                client.Open();
                var id = "POIUYTREWQ123456789876543210.0123ZXCVBNM<";
                Console.WriteLine($"Send cmdID:{id}");
                var data = new SocketServerCSharp.ComData(5)
                {
                    result = 0,
                    cData = id.PadRight(256, '\0').ToCharArray(),
                };
                data.iData[3] = 999;
                data.dData[4] = 9.00003;
                client.Sendcmd(data);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            Console.ReadKey();
            client.close();
        }

        private static void Client_ReceiveEvent(SocketServerCSharp.ComData data)
        {
            Console.WriteLine($"Receive cmdID:{data.cmdID}");
            Console.WriteLine($"cData:{(new string(data.cData)).TrimEnd('\0')}");
            Console.WriteLine($"iData[3]:{data.iData[0]}");
            Console.WriteLine($"dData[4]:{data.dData[0]}");
            Console.WriteLine($"result:{data.result}");
        }
    }
}
